/*
 * @Author: dvlproad
 * @Date: 2023-12-13 11:12:24
 * @LastEditors: dvlproad
 * @LastEditTime: 2023-12-13 11:15:25
 * @Description: 
 */
import 'package:flutter/cupertino.dart';
import 'package:transparent_image/transparent_image.dart';
import 'package:fluttertoast/fluttertoast.dart';

import '../model/entity.dart';

class ToolItemWidget extends StatefulWidget {
  final ToolBarEntity item;

  const ToolItemWidget({
    Key? key,
    required this.item,
  }) : super(key: key);

  @override
  State<ToolItemWidget> createState() => _ToolItemWidgetState();
}

class _ToolItemWidgetState extends State<ToolItemWidget> {
  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: GestureDetector(
        behavior: HitTestBehavior.translucent,
        onTap: () {
          _onHeaderItemClick(widget.item);
        },
        child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            ClipOval(
              child: FadeInImage.memoryNetwork(
                  image: widget.item.picUrl,
                  placeholder: kTransparentImage,
                  width: 62,
                  height: 62),
            ),
            Container(
              height: 6,
            ),
            Text(
              widget.item.title,
              style: const TextStyle(
                fontSize: 12,
                color: Color(0xff333333),
              ),
            )
          ],
        ),
      ),
    );
  }

  _onHeaderItemClick(ToolBarEntity item) {
    Fluttertoast.showToast(msg: item.title);
  }
}
